

function EFFECT:Init( data )
	
	// Keep the start + ending pos - interpolate between them
	self.Ent = data:GetEntity()
	if self.Ent == nil or self.Ent == NULL then return end
	
	self.Pos = data:GetOrigin()
	self.Ang = self.Ent:GetAngles()
	
	self.DieTime = CurTime() + math.Rand(3,6)
	self.Emitter = ParticleEmitter( self.Pos )
	
	self.LightColor = render.GetLightColor( self.Pos ) * 255
	self.LightColor.r = math.Clamp( self.LightColor.r, 70, 255 )
	//self.LightColor.g = math.Clamp( self.LightColor.g, 70, 255 )
	//self.LightColor.b = math.Clamp( self.LightColor.b, 70, 255 )
	
end


/*---------------------------------------------------------
   THINK
   Returning false makes the entity die
---------------------------------------------------------*/
function EFFECT:Think( )

	if self.Ent == nil or self.Ent == NULL then 
		if self.Emitter then
			self.Emitter:Finish()
		end
	return false end
	if self.DieTime < CurTime() then self.Emitter:Finish() return false end
	
	local head = self.Ent:GetPhysicsObjectNum( 12 )
	
	if head then
		self.Pos = head:GetPos()
		self.Ang = head:GetAngles() + Angle(-90,0,0)
	else
		self.Pos = self.Ent:GetPos()
		self.Ang = Angle(-90,0,0)
	end
		
	for i=1, math.random(2,4) do
		
		local particle = self.Emitter:Add( "effects/blood", self.Pos )

		particle:SetVelocity( self.Ang:Forward() * math.Rand( 120, 150 ) )
		particle:SetDieTime( math.Rand( 0.5, 1.0 ) )
		particle:SetStartAlpha( 180 )
		particle:SetEndAlpha( 10 )
		particle:SetStartSize( math.Rand( 1, 2 ) )
		particle:SetEndSize( math.Rand( 8, 12 ) )
		particle:SetRoll( math.Rand( 0, 90 ) )
		particle:SetRollDelta( math.Rand( -0.5, 0.5 ) )
		particle:SetColor( self.LightColor.r*0.5, 0, 0 )
		
		particle:SetGravity( Vector( 0, 0, -600 ) )
		particle:SetCollide( true )
		particle:SetBounce( .1 )
		
	end
	
	local particle2 = self.Emitter:Add( "effects/blood_core", self.Pos )
		
	particle2:SetVelocity( self.Ang:Forward() * math.Rand( 120, 150 ) + VectorRand() * 5 )
	particle2:SetDieTime( math.Rand( 0.5, 1 ) )
	particle2:SetStartAlpha( 80 )
	particle2:SetEndAlpha( 1 )
	particle2:SetStartSize( math.Rand( 1, 2 ) )
	particle2:SetEndSize( math.Rand( 12, 18 ) )
	particle2:SetRoll( math.Rand( 0, 360 ) )
	particle2:SetRollDelta( math.Rand( -0.5, 0.5 ) )
	particle2:SetColor( self.LightColor.r*0.5, 0, 0 )
		
	particle2:SetGravity( Vector( 0, 0, -600 ) )
	particle2:SetCollide( true )
	particle2:SetBounce( .1 )
	
	return true
	
end


/*---------------------------------------------------------
   Draw the effect
---------------------------------------------------------*/
function EFFECT:Render()

	// Do nothing - this effect is only used to spawn the particles in Init
	
end



